package cn.fldong.employee.servlet;

import cn.fldong.employee.dao.EmployeeDao;
import cn.fldong.employee.entity.EmployeeEntity;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.util.ArrayList;

@WebServlet("/querylist")
public class QueryListServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        EmployeeDao dao = new EmployeeDao();
        // 查询员工列表
        ArrayList<EmployeeEntity> employees = dao.queryAll();
        req.setAttribute("employees", employees);
        req.getRequestDispatcher("showInfo.jsp").forward(req, resp);
    }
}
